package comms;

/**
 * Commands recognised from the Kinect that may be handled by the app. 
 * 
 * Feed server message into here and switch over result for commands interested in.
 * 
 * @author norrielm
 *
 */
public class KinectInterface {

	public static enum commands {
		//app 
		HOTSPOT, 
		//store data 
		ANGLE, POS,
		//user tracking update
		TRACKING_ON, TRACKING_OFF, LOST_USER, NEW_USER,
		//gestures
		CLICK, SELECT, PUSH, RAISE_HAND, CIRCLE, WAVE,
		SWIPE_UP, SWIPE_DOWN, SWIPE_L, SWIPE_R,
		//comms 
		ACK, EXIT, 
		//default
		UNDEFINED}; 
	
	public static KinectInterface.commands handleKinectMessage(String s){
		s = s.toLowerCase();
	
		//Exit app
		if(s==null || s.toLowerCase().contains("exit"))
			return commands.EXIT;

		else if(s.contains("ack"))
			return commands.ACK;

		/* ******* */
		
		//Tracking started/ended
		else if(s.contains("accel") && s.contains("on"))
				return commands.TRACKING_ON;
		
		else if(s.contains("accel") && s.contains("off"))
				return commands.TRACKING_OFF;
		

		else if(s.contains("new user"))
			return commands.NEW_USER;
		
		//lost user
		else if(s.contains("lost user"))
			return commands.LOST_USER;

		/* ******* */
		//gestures
		else if(s.contains("click"))
			return commands.CLICK;

		else if(s.contains("select"))
			return commands.SELECT;

		else if(s.contains("push"))
			return commands.PUSH;

		else if(s.contains("circle"))
			return commands.CIRCLE;
		
		else if(s.contains("wave"))
			return commands.WAVE;
		
		else if(s.contains("raise hand"))
			return commands.RAISE_HAND;

		else if(s.contains("swipe left"))
			return commands.SWIPE_L;
		else if(s.contains("swipe right"))
			return commands.SWIPE_R;
		else if(s.contains("swipe up"))
			return commands.SWIPE_UP;
		else if(s.contains("swipe down"))
			return commands.SWIPE_DOWN;
		/* ******* */
		//Pose
		else if(s.contains("pose")) //avoid confusion with pos
			return commands.UNDEFINED;
		//Hand 
		else if(s.contains("pos"))
			return commands.POS;
		
		//Angle
		else if(s.contains("angle"))
			return commands.ANGLE;

		//Hotspot: Forward to phone
		else if(s.contains("hotspot"))
			return commands.HOTSPOT;			
		

		/* ******* */
		
		//None
		else
			return commands.UNDEFINED;
	}
	
	
}
